package com.atguigu.gulimall.product.config;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author 孙宏宇
 * @date 2021/6/9 15:37
 */
@Configuration
@EnableTransactionManagement  // 开启事务
@MapperScan("com.atguigu.gulimall.product.dao")
public class MyBatisConfig {

    /**
     * 引入分页插件
     * @return
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
        // 大于最后一页后，回到第一页
        paginationInterceptor.setOverflow(true);
        // 每页最大1000条
        paginationInterceptor.setLimit(1000);

        return paginationInterceptor;
    }

}
